Socket
Socket
Sign inDemoInstall

cli-table

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-table

Pretty unicode tables for the CLI


Version published
Maintainers
2
Created

What is cli-table?

The cli-table npm package is a utility for rendering unicode-aided tables on the command line from your node.js scripts. It allows for easy table creation with customizable column widths, alignments, colors, and more, making it highly useful for CLI tools that need to display data in a structured format.

What are cli-table's main functionalities?

Basic Table Creation

This feature allows for the creation of a simple table with rows of data. The example demonstrates how to instantiate a table, add rows, and then print it to the console.

const Table = require('cli-table');
let table = new Table();
table.push(
    ['First row', 'Some data'],
    ['Second row', 'More data']
);
console.log(table.toString());

Customized Table

This feature showcases the ability to customize the table with headers and column widths. The code sample creates a table with specified headers and column widths, adds rows of data, and prints the table.

const Table = require('cli-table');
let table = new Table({
    head: ['ID', 'Name', 'Age'],
    colWidths: [10, 20, 10]
});
table.push(
    [1, 'John Doe', 30],
    [2, 'Jane Doe', 25]
);
console.log(table.toString());

Table with Colored and Aligned Text

This feature demonstrates the ability to add colored and aligned text within table cells. The example shows how to align text horizontally and vertically within cells.

const Table = require('cli-table');
let table = new Table();
table.push(
    [{content: 'Left align', hAlign: 'left', vAlign: 'top'}, 'Some data'],
    [{content: 'Right align', hAlign: 'right'}, 'More data']
);
console.log(table.toString());

Other packages similar to cli-table

Keywords

FAQs

Package last updated on 06 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc